﻿@using KMF.Common;
@using KMF.WebUI.CustomHelpers
@model List<ProductCategoryMenuLeftDto>
@{
    var cate = ViewBag.pCate;
}
<ul>

    @if (Model.Any())
    {
        var css = "";
        var parentCategory = Model.Where(c => c.ParentId == "0");

        if (parentCategory.Any())
        {
            foreach (var c in parentCategory)
            {
                var lnkCate = Url.Action("Index", "CategoryL1", new { cate = c.Id,cateName = c.Name });
                css = "";
                if (cate == c.Id)
                {
                    css = "class='menu_left_active'";
                }
                var childrenCategory = Model.Where(pc => pc.ParentId == c.Id);
                
        <li>

            <a @Html.Raw(css) href="@lnkCate">@c.Name</a>

            @if (childrenCategory.Any())
            {
                         
                <ul>
                    @foreach (var child in childrenCategory)
                    {
                        var lnkChildCate = Url.Action("ProductByCateL2", "CategoryL1", new { cateId = child.Id, catefil = "OEJHY", cateName = child.Name });
                        css = "";
                        if (cate == child.Id)
                        {
                            css = "class='menu_left_active'";
                        }     
                        <li>

                            <a @Html.Raw(css) href="@lnkChildCate">@child.Name</a>

                        </li>
                    }
                </ul>
                                
            }

        </li>
            }
        }

    }
</ul>
